<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ include file="/WEB-INF/jsp/header.jsp" %>

<script language="JavaScript"> 
	document.getElementById('companies').style.display = 'block';
</script>

<%@ include file="/WEB-INF/jsp/partnerTools.jsp" %>

<h2> Companies for sale </h2>

<h3> Last update: <c:out value="${updateTime}"/> ago </h3>

<table class="searchTable">
	<form:form method="POST" commandName="companySearchCriteria">
	
	<tr>
		<td>
			Quality:
		</td>
		<td>
			<form:select path="companyQuality">
				<form:options itemLabel="name"/>
			</form:select>
		</td>
	</tr>
	
	<tr>
		<td>
			Select companyType:
		</td>
		<td>
			<form:select path="productType">
				<form:option value="">All products</form:option>
				<form:options itemLabel="name"/>
			</form:select>
		</td>

	</tr>
	
	
	<tr>
		<td>
			Select minimum stock:
		</td>
		<td>
			<form:select path="minimumStock">
				<form:options itemLabel="value"/>
			</form:select>
		</td>

	</tr>	
	
	
		
	<tr>
		<td>
			Select country:
		</td>
		<td>
			<form:select path="country">
				<form:option value="">All countries</form:option>
				<form:options  itemLabel="name" />
			</form:select>
		</td>

	</tr>
	
	

		
	<tr>
		<td>
			Minimal license number:
		</td>
		<td>
			<form:select path="licencesNumber">
				<form:options  itemLabel="value" />
			</form:select>
		</td>

	</tr>
	
	
	
	<tr>
		<td colspan="2">
			<center><input type="submit" value="Show"></center>
		</td>
	</tr>
	</form:form>
</table>
<br/>

<%@ include file="/WEB-INF/jsp/commercials.jsp" %>





<table width="900" border="2" cellpadding="2" cellspacing="0" bordercolor="777777" width="800" style="text-align: center; font-size: 11px">
	
		<tr style="background: #c0c0c0"> 
			<td>Company location  </td> 
			<td>Company name  </td> 
			<td>Product type</td>
			<td>Quality</td> 
			<td>Price</td>
			<td>Licences</td>
			<td>Stock size</td>
			<td>Raw size</td>
			<td>Employes number</td>
			<td>Daily profit</td>
		</tr>
	
		<c:forEach var="company" items="${companies}" >
			<tr style="background: none repeat scroll 0% 0% <c:out value="${company.country.alliance.color}"/>;">

			<td> 
				<img src="http://www.erepublik.com/images/flags/M/<c:out value="${company.country.urlName}"/>.gif"/><br/>
				<c:out value="${company.country.name}"/> (<c:out value="${company.country.alliance.name}"/>)
			</td>
			
			<td>
			<a href="http://economy.erepublik.com/en/company/dupaDupuDUPA/<c:out value="${company.id}"/>" target="_blank">
						<c:out value="${company.name}"/>
				</a>
				
			</td>
			
			<td>
			
				<c:if test="${company.productType.raw == true}">
					<img width="32" src="http://www.erepublik.com/images/icons/industry/<c:out value="${company.productType.erepublikId}"/>/default.png"/>
				</c:if>
				<c:if test="${company.productType.raw != true}">
					<img width="32" src="http://www.erepublik.com/images/icons/industry/<c:out value="${company.productType.erepublikId}"/>/q<c:out value="${company.quality}"/>.png"/><br/>			
				</c:if>		
			
			
				<br/>
				<c:out value="${company.productType}"/>
				
				<c:if test="${company.productType.raw == true}">
					<br/>${company.rawRegionDescription}
				</c:if>

				
			</td>
			<td>
				<c:if test="${company.productType.raw != true}">
					Q<c:out value="${company.quality}"/>
				</c:if>
				<c:if test="${company.productType.raw == true}">
					n/a
				</c:if>				
			</td>
			<td><c:out value="${company.price}"/> <img src="http://34all.org/erep/gold.gif"/></td>


			<td>
				<c:forEach var="license" items="${company.licenses}" >
					
						<img src="http://www.erepublik.com/images/flags/M/<c:out value="${license.country.urlName}"/>.gif"/> 
				
				</c:forEach>
			</td>

			<td><c:out value="${company.stockSize}"/></td>
			<td>
			
				<c:if test="${company.productType.raw == true}">
					n/a
				</c:if>
				<c:if test="${company.productType.raw != true}">
					<c:out value="${company.rawSize}"/>
				</c:if>		
			
			
			</td>
			<td><c:out value="${company.employesNumber}"/></td>
			
			<td>
				<c:if test="${company.productType.name != 'Hospital' }">
					<c:out value="${company.dailyProfit}"/>
					<img src="http://34all.org/erep/gold.gif"/><br/>
					
					<a href="companySimulator.html?country=<c:out value="${company.country}"/>&quality=<c:out value="${company.quality}"/>&productType=<c:out value="${company.productType}"/>&rawRegion=<c:out value="${company.rawRegion}"/>" >view report</a>
				</c:if>		
			</td>
	
			</tr>
		</c:forEach>
	
</table>


<%@ include file="/WEB-INF/jsp/bottom.jsp" %>

